<div id="content">
	<h2>Buku Tamu</h2>
	<div id="left">
	<div class="post">
		<form action="?page=addbukutamu&action=post" method="post">
		<table border="0" cellpadding="2" cellspacing="2">
			<tr>
				<td>Nama</td><td><input type="text" name="nama"></td>
			</tr>
			<tr>
				<td>Email</td><td><input type="text" name="email"></td>
			</tr>
			<tr>
				<td>Isi</td><td><textarea name="isi" cols="75" rows="8" width="60%"></textarea></td>
			</tr>
			<tr>
				<td colspan="2"><input type="submit" value="Kirim"></td>
			</tr>
		</table>
		</form>
	</div>
</div>
</div>

<?php

if ($_GET['action'] == "post") {
	
	require('class/config.php');
	$nama  = htmlentities(mysql_real_escape_string($_POST['nama']));
	$email = htmlentities(mysql_real_escape_string($_POST['email']));
	$isi   = htmlentities(mysql_real_escape_string($_POST['isi']));
	$sql   = mysql_query("INSERT INTO `bukutamu` (`nama`,`email`,`isi_bukutamu`) VALUES ('".$nama."', '".$email."', '".$isi."')");

	if ($sql) {
		?>
			<script>
				alert("Buku tamu berhasil dikirim");
				document.location="?page=bukutamu";
			</script>
		<?php
	} else {
		?>
			<script>
				alert("Buku tamu gagal dikirim");
				document.location="?page=bukutamu";
			</script>
		<?php
	}
}
